#ifndef __SQL_CONN_RAII__
#define __SQL_CONN_RAII__

#include "sqlconpool.h"

class SqlConnRAII
{
public:
    SqlConnRAII(MYSQL **sql, SqlConnPool *sqlpool)
    {
        assert(sqlpool);
        *sql = sqlpool->GetConn();
        sql_ = *sql;
        sqlconnpool_ = sqlpool;
    }
    ~SqlConnRAII()
    {
        if (sql_)
            sqlconnpool_->FreeConn(sql_);
        std::cout<<"析构"<<std::endl;
    }

private:
    MYSQL *sql_;
    SqlConnPool *sqlconnpool_;
};

#endif